using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace FiltronASP.Models.Validators
{
    /// <summary>
    /// Walidator sprawdzajacy czy wprowadzona wartosc pasuje do adresu strony.
    /// </summary>
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
    public class HttpAttribute : RegularExpressionAttribute
    {
        private const string _pattern = @"^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&amp;%\$#\=~])*[^\.\,\)\(\s]$";
        //private const string _pattern = @"^(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'"".'""'."".,<>?«»“”‘’]))$";
        /// <summary>
        /// Konstruktor.
        /// </summary>  
        public HttpAttribute()
            : base(_pattern)
        {
        }

    }
}
